// https://www.luogu.com.cn/problem/P3478
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
using ll = long long;
const int inf = 0x3f3f3f3f;
#define rf(i, n) for (int i = 1; i <= (n); ++i)
int rad(); // read int
const int max_size = 5 + 100;
const int maxn = 5 + 1e6;

int n;
vector<int> adj[maxn];
ll f[maxn], siz[maxn];

void init(int now = 1, int fa = 0) {
    siz[now] = 1;
    for (auto &p : adj[now]) {
        if (p == fa) continue;
        init(p, now);
        siz[now] += siz[p];
        f[now] += siz[p] + f[p];
    }
}

void dfs(int now = 1, int fa = 0) {
    for (auto &p : adj[now]) {
        if (p == fa) continue;
        f[p] = f[now] - siz[p] + n - siz[p];
        dfs(p, now);
    }
}

int main() {
    n = rad();
    rf(i, n - 1) {
        int l = rad(), r = rad();
        adj[l].push_back(r), adj[r].push_back(l);
    }

    init();
    dfs();
    int ans = 1;
    for (int i = 2; i <= n; ++i) {
        if (f[i] > f[ans]) ans = i;
    }
    printf("%d", ans);
}

int rad() {
    int back = 0, ch = 0, posi = 0;
    for (; ch < '0' || ch > '9'; ch = getchar())
        posi = ch ^ '-';
    for (; ch >= '0' && ch <= '9'; ch = getchar())
        back = (back << 1) + (back << 3) + (ch & 0xf);
    return posi ? back : -back;
}

/*
8 1 4 5 6 4 5 6 7 6 8 2 4 3 4

*/